//
//  MVTableViewCell.m
//  花花时尚
//
//  Created by zhang on 15/10/6.
//  Copyright (c) 2015年 ggs. All rights reserved.
//

#import "MVTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "ArtistModel.h"
#import "VideoMode.h"
#import "Define.h"

@interface MVTableViewCell ()
@property (nonatomic, retain)UIImageView *posterPic;
@property (nonatomic, retain)UILabel *totalViews;
@property (nonatomic,retain)UILabel *title;
@property (nonatomic, retain)UILabel *artistName;

@end
@implementation MVTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 10;
        
        [self creatView];
    }
    return self;
}
- (void)creatView
{
    UIView *hoder = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 375 * REAL_WIDTH, 180 * REAL_HEIGTH)];
    hoder.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.2];
    
    self.posterPic = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 375 * REAL_WIDTH, 180 * REAL_HEIGTH)];
    self.posterPic.backgroundColor = [UIColor blackColor];
    [self.contentView addSubview:self.posterPic];
    [self.posterPic addSubview:hoder];
    [hoder release];
    [self.posterPic release];
    
    self.title = [[UILabel alloc] initWithFrame:CGRectMake(10, self.posterPic.frame.size.height - 60 * REAL_HEIGTH, 375 * REAL_WIDTH, 15 * REAL_HEIGTH)];
    self.title.backgroundColor = [UIColor clearColor];
    self.title.textColor = [UIColor whiteColor];
    [hoder addSubview:self.title];
    [self.title release];
    
    self.artistName = [[UILabel alloc] initWithFrame:CGRectMake(10, self.title.frame.origin.y + self.title.frame.size.height + 5, self.title.frame.size.width, self.title.frame.size.height)];
    self.artistName.backgroundColor = [UIColor clearColor];
    self.artistName.textColor = [UIColor colorWithRed:0.2 green:0.8 blue:0.2 alpha:1];
    [hoder addSubview:self.artistName];
    [self.artistName release];
    
    self.totalViews = [[UILabel alloc] initWithFrame:CGRectMake(10, self.artistName.frame.origin.y + self.artistName.frame.size.height + 5, self.title.frame.size.width, self.title.frame.size.height)];
    self.totalViews.backgroundColor = [UIColor clearColor];
    self.totalViews.textColor = [UIColor whiteColor];
    [hoder addSubview:self.totalViews];
    [self.totalViews release];
    
    
}
/*
 * 给cell的View赋值
 */
- (void)setValueWith:(VideoMode *)video artist:(ArtistModel *)artist
{
    NSURL *url = [NSURL URLWithString:video.posterPic];
    [_posterPic sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"MV_holder.jpg"]];
    _title.text = video.title;
    _artistName.text = artist.artistName;
    _totalViews.text = [NSString stringWithFormat:@"播放次数:%@", video.totalViews];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
